package cn.zebra.dev.other.module.shopAdmin.service.impl;

import cn.zebra.dev.ibatis.plus.service.impl.ServiceImpl;
import cn.zebra.dev.ibatis.plus.utils.PageUtils;
import cn.zebra.dev.ibatis.plus.utils.Query;
import cn.zebra.dev.other.module.shopAdmin.dao.ShopAdminDao;
import cn.zebra.dev.other.module.shopAdmin.entity.ShopAdminEntity;
import cn.zebra.dev.other.module.shopAdmin.service.ShopAdminService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 *
 * @author runnable
 */
@Service
public class ShopAdminServiceImpl extends ServiceImpl<ShopAdminDao, ShopAdminEntity> implements ShopAdminService {

    @Override
    public PageUtils<ShopAdminEntity> findPage(Map<String, Object> params) {
        QueryWrapper<ShopAdminEntity> wrapper = new QueryWrapper<>();
        IPage<ShopAdminEntity> page = this.page(
                new Query<ShopAdminEntity>(params).getPage(),
                wrapper
        );

        return new PageUtils<>(page);
    }

    @Override
    public ShopAdminEntity findShopIdByUserId(Long id) {
        QueryWrapper<ShopAdminEntity> wrapper = new QueryWrapper<>();
        wrapper.select("shop_id ");
        wrapper.apply("user_id = {0}",id);
        return getOne(wrapper);
    }
}
